package cn.ffcs.uec.insurance.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import cn.ffcs.uom.common.constants.BaseUnitConstants;
import cn.ffcs.uom.common.model.UomEntity;
import cn.ffcs.uom.common.util.StrUtil;
import lombok.Getter;
import lombok.Setter;
/**
 * 险种期间状态
 *
 */
public class UecPeriodstate extends UomEntity implements Serializable {

	private static final long serialVersionUID = -1550327753173687989L;


	/**
	 * 险种期间状态主键
	 * 
	 */
	public Long getUecPeriodstateId() {
		return super.getId();
	}

	public void setUecPeriodstateId(Long uecPeriodstateId) {
		super.setId(uecPeriodstateId);
	}

	/**
	 * 账期
	 */
	@Getter
	@Setter
	private Long monthId;
	/**
	 * 险种期间状态主键
	 */
	@Getter
	@Setter
	private String pkPeriodstate;
	/**
	 * 险种主键
	 */
	@Getter
	@Setter
	private Long uecBmclassId;
	/**
	 * 险种主键
	 */
	@Getter
	@Setter
	private String pkBmClass;
	/**
	 * 险种期间
	 */
	@Getter
	@Setter
	private Long uecPeriodId;
	/**
	 * 险种期间
	 */
	@Getter
	@Setter
	private String uecPeriodName;
	/**
	 * 险种期间
	 */
	@Getter
	@Setter
	private String pkBmPeriod;
	/**
	 * 计算标志
	 */
	@Getter
	@Setter
	private String recacuflag;
	/**
	 * 审核标志
	 */
	@Getter
	@Setter
	private String checkflag;
	/**
	 * 结帐标志
	 */
	@Getter
	@Setter
	private String accountmark;
	/**
	 * 操作员
	 */
	@Getter
	@Setter
	private String operatorid;
	/**
	 * 结帐日期
	 */
	@Getter
	@Setter
	private String daccountdate;
	/**
	 * 集团主键
	 */
	@Getter
	@Setter
	private String pkGroup;
	/**
	 * 组织主键
	 */
	@Getter
	@Setter
	private Long orgId;
	/**
	 * 组织主键
	 */
	@Getter
	@Setter
	private String pkOrg;
	/**
	 * 生效标示
	 */
	@Getter
	@Setter
	private String enableflag;
	/**
	 * 是否发放
	 */
	@Getter
	@Setter
	private String isapproved;
	/**
	 * 
	 */
	@Getter
	@Setter
	private String ts;
	/**
	 * 
	 */
	@Getter
	@Setter
	private Long dr;
	
	@Setter
	private UecPeriod uecPeriod;
	
	public UecPeriod getUecPeriod() {
		if (this.uecPeriod != null) {
			return this.uecPeriod;
		} else {
			StringBuilder sql =new StringBuilder ("SELECT * FROM UEC_PERIOD T WHERE T.STATUS_CD = ? ");
			List<Object> params = new ArrayList<Object>();
			params.add(BaseUnitConstants.ENTT_STATE_ACTIVE);
			if (!StrUtil.isEmpty(this.getPkBmPeriod())) {
				sql.append(" AND T.PK_BM_PERIOD   = ? ");
				params.add(this.getPkBmPeriod());
			} else if (this.getUecPeriodId() != null) {
				sql.append(" AND T.UEC_PERIOD_ID = ? ");
				params.add(this.getUecPeriodId());
			}
			
			List<UecPeriod> list = UecPeriod.repository()
					.jdbcFindList(sql.toString(), params, UecPeriod.class);
			if (list != null && list.size() > 0) {
				return list.get(0);
			}
		}

		return null;
	}

	public static UecPeriodstate newInstance() {
		return new UecPeriodstate();
	}
	
}
